function modifyName() {
    nameBtn.readonlyMode = !nameBtn.readonlyMode

    if (!nameBtn.readonlyMode)
        return


    if (textName.text.trim().length < 2)
    {
        dialog.message("姓名不能小于2个字符");
        return;
    }


    nav.initializeTask(0, 2, "正在修改姓名....")
    nav.openTask("修改姓名");

    http.put("/member.json?t=n", {id: usinfo.id}, {
                 name: textName.text.trim()
             }, function(json){
                 nav.value = nav.maximumValue

                 if (json.error) {
                     dialog.toast(json.error.description)
                     return
                 }

                 usinfo.name = textName.text.trim()
                 dialog.toast("修改成功")
             })

    nav.value++
}

function modifyMail() {
    mailBtn.readonlyMode = !mailBtn.readonlyMode

    if (!mailBtn.readonlyMode)
        return


    var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/

     if(!reg.test(textMail.text.trim()))
    {
        dialog.message("邮箱格式不正确");
        return;
    }

    nav.initializeTask(0, 2, "正在修改邮箱....")
    nav.openTask("修改邮箱");

    http.put("/member.json?t=m", {id: usinfo.id}, {
                 mail: textMail.text.trim()
             }, function(json){
                 nav.value = nav.maximumValue

                 if (json.error) {
                     dialog.toast(json.error.description)
                     return
                 }
                 usinfo.mail = textMail.text.trim()

                 dialog.toast("修改成功")
             })

    nav.value++
}

function modify() {
    if (passwordTxt.text.trim().length < 6)
    {
        dialog.message("密码不能小于6位!");
        return;
    }

    if (passText.text.trim() != passwordTxt.text.trim()) {
        dialog.message("两次密码不一致!");
        return;
    }

    nav.initializeTask(0, 2, "正在修改密码....")
    nav.openTask("修改密码");

    http.put("/member.json?t=p", {   id: usinfo.id}, {
                 password: Qt.md5(passText.text.trim()).toUpperCase()
             }, modifyResult)

    nav.value++
}

function modifyResult(json) {
    nav.value = nav.maximumValue

    if (json.error) {
        dialog.toast(json.error.description)
        return
    }

    dialog.toast("修改成功")
}
